# -*- coding:utf-8 -*-

from django.db import models
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class AbstractTMobileTyping(models.Model):
    SEX = (('male', '男'), ('female', '女'), ('', '未知'),)
    INIT = 0
    PICKED = 1
    STATUS = ((INIT, '初始化'), (PICKED, '已提取'),)

    mobile = models.CharField(max_length=20, blank=False, null=False, default='', verbose_name='手机号'
                              , unique=True)
    note = models.CharField(max_length=90, blank=True, null=False, default='', verbose_name='注释')
    name = models.CharField(max_length=45, blank=False, null=False, default='', verbose_name='姓名')
    sex = models.CharField(max_length=10, blank=True, null=False, default='', verbose_name='性别', choices=SEX)
    user_name = models.CharField(max_length=45, blank=True, null=False, default='', verbose_name='微信号')
    create_user = models.CharField(max_length=150, blank=False, null=False, default='', verbose_name='创建人'
                                   , editable=False)
    client_ip = models.CharField(max_length=20, blank=False, null=False, default='', verbose_name='IP'
                                 , editable=False)
    ctime = models.DateTimeField(auto_now_add=True, editable=False, verbose_name='创建时间')
    category_name = models.CharField(max_length=90, blank=False, null=False, default='', verbose_name='类别',
                                     editable=False)
    channel_name = models.CharField(max_length=90, blank=False, null=False, default='', verbose_name='渠道',
                                    editable=False)
    status = models.IntegerField(blank=False, null=False, default=0, verbose_name='状态', choices=STATUS)
    status_text = models.CharField(max_length=90, blank=False, null=False, default='', verbose_name='状态描述')
    mtime = models.DateTimeField(auto_now=True, editable=False, verbose_name='修改时间')

    class Meta:
        managed = False
        db_table = 't_mobile_typing'
        abstract = True
        verbose_name = '录入数据'
        verbose_name_plural = '录入数据'

    def __str__(self):
        return self.mobile


@python_2_unicode_compatible
class TMobileTyping(AbstractTMobileTyping):
    class Meta:
        managed = False
        db_table = 't_mobile_typing'
        verbose_name = '录入数据'
        verbose_name_plural = '录入数据'


@python_2_unicode_compatible
class TMobilePicking(AbstractTMobileTyping):
    class Meta:
        managed = False
        db_table = 't_mobile_typing'
        verbose_name = '1.0 提取数据'
        verbose_name_plural = '1.0 提取数据'
        app_label = 'manualpick'
